public class CumulativePolarity {
  int numPositive;
  int numNegative;
  int numNeutral;
  double cumulativeConfidence;

  public CumulativePolarity() {
    numPositive = 0;
    numNegative = 0;
    numNeutral = 0;
    cumulativeConfidence = 0.0;
  }

  public void addPositiveComment(double conf) {
    numPositive++;
    cumulativeConfidence += conf;
  }

  public void addNegativeComment(double conf) {
    cumulativeConfidence -= conf;
    numNegative++;
  }

  public void addNeutralComment() {
    numNeutral++;
  }

  public int getNumPositive() {
    return numPositive;
  }

  public int getNumNegative() {
    return numNegative;
  }

  public int getNumNeutral() {
    return numNeutral;
  }

  public int getCumulative() {
    return numPositive - numNegative;
  }
  
  public double getCumulativeConfidence() {
    if (numNegative != 0 && numPositive != 0)
      return cumulativeConfidence / (numNegative + numPositive);
    return 0.0;
  }

  public String toString() {
    String str = "";

    str += "Cumulative: " + getCumulative() + "\n";
    str += "Positive: " + numPositive + "\n";
    str += "Negative: " + numNegative + "\n";
    str += "Neutral: " + numNeutral + "\n";

    return str;
  }
}